<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- qvulkanwindow.cpp -->
  <title>QVulkanWindowRenderer Class | Qt GUI 5.14.2</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.14</a></td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QVulkanWindowRenderer</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.14.2 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QVulkanWindowRenderer Class</h1>
<!-- $$$QVulkanWindowRenderer-brief -->
<p>The QVulkanWindowRenderer class is used to implement the application-specific rendering logic for a <a href="qvulkanwindow.html">QVulkanWindow</a>. <a href="#details">More...</a></p>
<!-- @@@QVulkanWindowRenderer -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QVulkanWindowRenderer&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign"> Qt 5.10</td></tr></table></div><p>This class was introduced in Qt 5.10.</p>
<ul>
<li><a href="qvulkanwindowrenderer-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qvulkanwindowrenderer.html#dtor.QVulkanWindowRenderer">~QVulkanWindowRenderer</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qvulkanwindowrenderer.html#initResources">initResources</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qvulkanwindowrenderer.html#initSwapChainResources">initSwapChainResources</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qvulkanwindowrenderer.html#logicalDeviceLost">logicalDeviceLost</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qvulkanwindowrenderer.html#physicalDeviceLost">physicalDeviceLost</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qvulkanwindowrenderer.html#preInitResources">preInitResources</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qvulkanwindowrenderer.html#releaseResources">releaseResources</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qvulkanwindowrenderer.html#releaseSwapChainResources">releaseSwapChainResources</a></b>()</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QVulkanWindowRenderer-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>Applications typically subclass both <a href="qvulkanwindow.html">QVulkanWindow</a> and QVulkanWindowRenderer. The former allows handling events, for example, input, while the latter allows implementing the Vulkan resource management and command buffer building that make up the application's rendering.</p>
<p>In addition to event handling, the <a href="qvulkanwindow.html">QVulkanWindow</a> subclass is responsible for providing an implementation for <a href="qvulkanwindow.html#createRenderer">QVulkanWindow::createRenderer</a>() as well. This is where the window and renderer get connected. A typical implementation will simply create a new instance of a subclass of QVulkanWindowRenderer.</p>
</div>
<!-- @@@QVulkanWindowRenderer -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$~QVulkanWindowRenderer[overload1]$$$~QVulkanWindowRenderer -->
<h3 class="fn" id="dtor.QVulkanWindowRenderer"><a name="dtor.QVulkanWindowRenderer"></a><code>[virtual] </code>QVulkanWindowRenderer::<span class="name">~QVulkanWindowRenderer</span>()</h3>
<p>Virtual destructor.</p>
<!-- @@@~QVulkanWindowRenderer -->
<!-- $$$initResources[overload1]$$$initResources -->
<h3 class="fn" id="initResources"><a name="initResources"></a><code>[virtual] </code><span class="type">void</span> QVulkanWindowRenderer::<span class="name">initResources</span>()</h3>
<p>This virtual function is called when it is time to create the renderer's graphics resources.</p>
<p>Depending on the <a href="qvulkanwindow.html#Flag-enum">QVulkanWindow::PersistentResources</a> flag, device lost situations, etc. this function may be called more than once during the lifetime of a <a href="qvulkanwindow.html">QVulkanWindow</a>. However, subsequent invocations are always preceded by a call to <a href="qvulkanwindowrenderer.html#releaseResources">releaseResources</a>().</p>
<p>Accessors like device(), graphicsQueue() and graphicsCommandPool() are only guaranteed to return valid values inside this function and afterwards, up until <a href="qvulkanwindowrenderer.html#releaseResources">releaseResources</a>() is called.</p>
<p>The default implementation is empty.</p>
<!-- @@@initResources -->
<!-- $$$initSwapChainResources[overload1]$$$initSwapChainResources -->
<h3 class="fn" id="initSwapChainResources"><a name="initSwapChainResources"></a><code>[virtual] </code><span class="type">void</span> QVulkanWindowRenderer::<span class="name">initSwapChainResources</span>()</h3>
<p>This virtual function is called when swapchain, framebuffer or renderpass related initialization can be performed. Swapchain and related resources are reset and then recreated in response to window resize events, and therefore a pair of calls to <a href="qvulkanwindowrenderer.html#initResources">initResources</a>() and <a href="qvulkanwindowrenderer.html#releaseResources">releaseResources</a>() can have multiple calls to initSwapChainResources() and <a href="qvulkanwindowrenderer.html#releaseSwapChainResources">releaseSwapChainResources</a>() calls in-between.</p>
<p>Accessors like <a href="qvulkanwindow.html#swapChainImageSize">QVulkanWindow::swapChainImageSize</a>() are only guaranteed to return valid values inside this function and afterwards, up until <a href="qvulkanwindowrenderer.html#releaseSwapChainResources">releaseSwapChainResources</a>() is called.</p>
<p>This is also the place where size-dependent calculations (for example, the projection matrix) should be made since this function is called effectively on every resize.</p>
<p>The default implementation is empty.</p>
<!-- @@@initSwapChainResources -->
<!-- $$$logicalDeviceLost[overload1]$$$logicalDeviceLost -->
<h3 class="fn" id="logicalDeviceLost"><a name="logicalDeviceLost"></a><code>[virtual] </code><span class="type">void</span> QVulkanWindowRenderer::<span class="name">logicalDeviceLost</span>()</h3>
<p>This virtual function is called when the logical device (VkDevice) is lost, meaning some operation failed with <code>VK_ERROR_DEVICE_LOST</code>.</p>
<p>The default implementation is empty.</p>
<p>There is typically no need to perform anything special in this function. <a href="qvulkanwindow.html">QVulkanWindow</a> will automatically release all resources (invoking <a href="qvulkanwindowrenderer.html#releaseSwapChainResources">releaseSwapChainResources</a>() and <a href="qvulkanwindowrenderer.html#releaseResources">releaseResources</a>() as necessary) and will attempt to reinitialize, acquiring a new device. When the physical device was also lost, this reinitialization attempt may then result in <a href="qvulkanwindowrenderer.html#physicalDeviceLost">physicalDeviceLost</a>().</p>
<p><b>See also </b><a href="qvulkanwindowrenderer.html#physicalDeviceLost">physicalDeviceLost</a>().</p>
<!-- @@@logicalDeviceLost -->
<!-- $$$physicalDeviceLost[overload1]$$$physicalDeviceLost -->
<h3 class="fn" id="physicalDeviceLost"><a name="physicalDeviceLost"></a><code>[virtual] </code><span class="type">void</span> QVulkanWindowRenderer::<span class="name">physicalDeviceLost</span>()</h3>
<p>This virtual function is called when the physical device is lost, meaning the creation of the logical device fails with <code>VK_ERROR_DEVICE_LOST</code>.</p>
<p>The default implementation is empty.</p>
<p>There is typically no need to perform anything special in this function because <a href="qvulkanwindow.html">QVulkanWindow</a> will automatically retry to initialize itself after a certain amount of time.</p>
<p><b>See also </b><a href="qvulkanwindowrenderer.html#logicalDeviceLost">logicalDeviceLost</a>().</p>
<!-- @@@physicalDeviceLost -->
<!-- $$$preInitResources[overload1]$$$preInitResources -->
<h3 class="fn" id="preInitResources"><a name="preInitResources"></a><code>[virtual] </code><span class="type">void</span> QVulkanWindowRenderer::<span class="name">preInitResources</span>()</h3>
<p>This virtual function is called right before graphics initialization, that ends up in calling <a href="qvulkanwindowrenderer.html#initResources">initResources</a>(), is about to begin.</p>
<p>Normally there is no need to reimplement this function. However, there are cases that involve decisions based on both the physical device and the surface. These cannot normally be performed before making the <a href="qvulkanwindow.html">QVulkanWindow</a> visible since the Vulkan surface is not retrievable at that stage.</p>
<p>Instead, applications can reimplement this function. Here both <a href="qvulkanwindow.html#physicalDevice">QVulkanWindow::physicalDevice</a>() and <a href="qvulkaninstance.html#surfaceForWindow">QVulkanInstance::surfaceForWindow</a>() are functional, but no further logical device initialization has taken place yet.</p>
<p>The default implementation is empty.</p>
<!-- @@@preInitResources -->
<!-- $$$releaseResources[overload1]$$$releaseResources -->
<h3 class="fn" id="releaseResources"><a name="releaseResources"></a><code>[virtual] </code><span class="type">void</span> QVulkanWindowRenderer::<span class="name">releaseResources</span>()</h3>
<p>This virtual function is called when the renderer's graphics resources must be released.</p>
<p>The implementation must be prepared that a call to this function may be followed by an <a href="qvulkanwindowrenderer.html#initResources">initResources</a>() at a later point.</p>
<p><a href="qvulkanwindow.html">QVulkanWindow</a> takes care of waiting for the device to become idle before and after invoking this function.</p>
<p>The default implementation is empty.</p>
<!-- @@@releaseResources -->
<!-- $$$releaseSwapChainResources[overload1]$$$releaseSwapChainResources -->
<h3 class="fn" id="releaseSwapChainResources"><a name="releaseSwapChainResources"></a><code>[virtual] </code><span class="type">void</span> QVulkanWindowRenderer::<span class="name">releaseSwapChainResources</span>()</h3>
<p>This virtual function is called when swapchain, framebuffer or renderpass related resources must be released.</p>
<p>The implementation must be prepared that a call to this function may be followed by a new call to <a href="qvulkanwindowrenderer.html#initSwapChainResources">initSwapChainResources</a>() at a later point.</p>
<p><a href="qvulkanwindow.html">QVulkanWindow</a> takes care of waiting for the device to become idle before and after invoking this function.</p>
<p>The default implementation is empty.</p>
<p><b>Note: </b>This is the last place to act with all graphics resources intact before <a href="qvulkanwindow.html">QVulkanWindow</a> starts releasing them. It is therefore essential that implementations with an asynchronous, potentially multi-threaded startNextFrame() perform a blocking wait and call <a href="qvulkanwindow.html#frameReady">QVulkanWindow::frameReady</a>() before returning from this function in case there is a pending frame submission.</p><!-- @@@releaseSwapChainResources -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
